www.gusucode.com > 基于马尔科夫随机场的图像分割matlab源码。包括ICM迭代条件模式求解最大后验概率算法 > code23/matlab MRF toy examples/initLocalEvidence.m
% [nodes] = initLocalEvidence(nodes, image, p); % Given an input binary image of the appropriate resolution, and a % probability, p, that each pixel is flipped, initialize the local evidence % vector coming into each node. % october 5, 2003 wtf created. function [nodes] = initLocalEvidence(nodes, image, p); noisyImage = zeros(size(image)); iNode = 1; for j = 1:size(image,2) for i = 1:size(image,1) % assume q is 0-1 probability of being on. q = image(i,j); % probability of being up is: prob from image that it was up (q) * % prob that that bit wasn't flipped (1-p), plus prob from image % that it was down (1-q) * prob that that bit was flipped (p). % Similarly for prob of being down. nodes{iNode}.localEvidence = [q * (1-p) + (1-q) * p, (1-q) * (1-p) + q * p]; iNode = iNode +1; end end